package com.lengxf.redis.config.deser;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.lengxf.redis.config.RedisConstant;
import lombok.SneakyThrows;

import java.util.Date;

/**
 * Date类型反序列化
 *
 * @Author Lengxf
 */
public class DateDeserializer extends JsonDeserializer<Date> {

    @Override
    @SneakyThrows
    public Date deserialize(JsonParser p, DeserializationContext ctxt) {
        return RedisConstant.DATE_FORMAT.parse(p.getText());
    }

}
